<template>
    <div>
      <div class="head">
        <a @click="$router.back(-1)" class="return"></a>
        {{$t('ProjectProgress.v1')}}
      </div>
      <div class="overlay">
        <div class="overlay-content scrolling" style="padding-top: 10px;">
          <van-pull-refresh v-model="isLoading" @refresh="onRefresh" pulling-text=" " :loosing-text="$t('MyTeam.v8')"
                            :loading-text="$t('MyTeam.v7')">
            <van-list v-model="loading" :finished="finished" :finished-text="$t('Prize.v3')"
                      :loading-text="$t('MyTeam.v7')" @load="onLoad">
              <van-steps direction="vertical" :active="0">
                <van-step v-for="(item,index) in list" :key="item.index">
                  <h3 v-html="item.content" class="jsImg">【城市】物流状态1</h3>
                  <p>{{item.createTime | dateFormat}}</p>
                </van-step>
              </van-steps>
            </van-list>
          </van-pull-refresh>
        </div>
      </div>
    </div>
</template>

<script>
    import {crowdfunding} from './../../utils/api';
    import { dateFormat } from 'vux';
    export default {
        name: "ProjectProgress",
        data() {
            return {
                list: [],
                size: 10, // 每页数量
                current: 1,
                total: '', // 总数量
                listLength: '', //当前总数量
                isLoading: false,
                finished: false,
                loading: false,
            }
        },
        mounted() {
            this.getList();
        },
        methods: {
            getList() {
                crowdfunding.getProgress({
                    projectId: this.$route.query.projectId,
                    current: this.current,
                    size: this.size
                }).then(res => {
                    if(res.code == 200) {
                        this.list = res.data.records;
                        this.listLength = res.data.records.length;
                        this.total = res.data.total;
                        if (this.total > this.listLength) {
                            this.size += 10;
                            this.loading = false;
                        } else {
                            // 加载状态结束
                            this.finished = true;
                            this.loading = false;
                        }
                    }
                })
            },
            onRefresh() { // 下拉刷新
                this.getList();
                setTimeout(() => {
                    this.$toast({
                        duration: 800,
                        message: this.$t('Prize.v23')
                    });
                    this.isLoading = false;
                }, 500);
            },
            onLoad() { // 上拉加载
                this.getList();
            }
        },
        filters: {
            dateFormat
        }
    }
</script>

<style lang="less" scoped>
  .overlay {
    background: rgb(245, 245, 245);
  }

  .head {
    background: white;
    color: black;
  }

  .head .return:after {
    border-color: black;
  }

  /deep/ .jsImg img {
    width: 100%;
    height: 100%;
  }
</style>
